package com.mergeSort;

import com.Sort;

/**
 * @author 罗俊华
 * @date 2021/5/11 - 5:57 下午
 * 自底向上的归并排序
 */
public class MergeSortFromButtonToTop<Item extends Comparable<Item>> extends Sort<Item> {
    @Override
    public void sort(Item[] comparableArray) {
        MergeSort<Item> mergeSort = new MergeSort<>();
        for (int unitSize = 1; unitSize < comparableArray.length; unitSize++) {

            for (int low = 0; low < comparableArray.length - unitSize; low += unitSize + unitSize) {
                mergeSort.merge(comparableArray,low,low+unitSize);
            }

        }
    }
}
